/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */
const resolve = require('path').resolve;
const fs = require('fs');
const modulePaths = []
module.exports = {
  transformer: {
    // getTransformOptions: async () => ({
    //   transform: {
    //     experimentalImportSupport: false,
    //     inlineRequires: false,
    //   },
    // }),
    // getTransformOptions: () => {
    //   const moduleMap = {};
    //   modulePaths.forEach(path => {
    //     if (fs.existsSync(path)) {
    //       moduleMap[resolve(path)] = true;
    //     }
    //   });
    //   return {
    //     preloadedModules: moduleMap,
    //     transform: { inlineRequires: { blacklist: moduleMap } },
    //   };
    // },
    asyncRequireModulePath: 'metro/src/lib/bundle-modules/asyncRequire',
    assetRegistryPath: '/Users/grant/Desktop/ReactNativeStudy/node_modules/react-native/Libraries/Image/AssetRegistry',
    babelTransformerPath:
      '/Users/grant/Desktop/ReactNativeStudy/node_modules/metro-react-native-babel-transformer/src/index.js',
  },
  serializer: {
    getPolyfills: require('react-native/rn-get-polyfills'),
    createModuleIdFactory: () => {
      const fileToIdMap = new Map();
      let nextId = 0;
      return (path) => {
        let id = fileToIdMap.get(path);

        if (typeof id !== 'number') {
          id = nextId++;
          fileToIdMap.set(path, id);
        }
        return id;
      };
    },
    processModuleFilter: (m) => {
      return true;
    },
  },
};
